<template>
  <div id="home">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200">
        <div class="sao">
          <img
            src="../../../public/img/saotu.jpg"
            alt="图片加载失败"
            title="讨厌！！！"
          />
        </div>
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          :collapse="isCollapse"
          :router="true"
        >
          <qf-sub-menu :sideMenu="menuList"></qf-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- 顶栏 -->
        <el-header>
          <el-row type="flex" class="row-bg" justify="space-between">
            <el-col :span="6"
              ><div class="grid-content bg-purple">
                <span class="iconfont" @click="isCollapse = !isCollapse"
                  >&#xe759;</span
                >
              </div></el-col
            >
            <el-col :span="6"
              ><div class="grid-content bg-purple-light">
                小吴的管理系统
              </div></el-col
            >
            <el-col :span="6"
              ><div class="grid-content bg-purple">
                <el-avatar :size="40" :src="circleUrl"></el-avatar>&nbsp;
                <span>欢迎光临：</span>
                <span>{{ userInfo.nickname }}</span
                >&nbsp;
                <span @click="quit" class="quit">退出</span>
              </div></el-col
            >
          </el-row>
        </el-header>
        <!-- 主要内容栏 -->
        <el-main>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/Welcome' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{path:crumb.path}" v-for="crumb in crumbs">
              {{crumb.meta.name}}
            </el-breadcrumb-item>
          </el-breadcrumb>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
// import { getLoginLog } from "@/api";
import { mapState } from "vuex";
export default {
  data() {
    return {
      isCollapse: false,
      circleUrl:
        "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=416631127,2774969345&fm=26&gp=0.jpg",
    };
  },
  computed: {
    ...mapState(["userInfo", "menuList","crumbs"]),
  },
  methods: {
    quit() {
      //退出登录
      //1、清楚token和userInfo
      localStorage.removeItem("ajaj-userInfo");
      localStorage.removeItem("ajaj-token");

      //2、跳转到登入页
      this.$router.push("./login");
      //刷新页面
      window.location.reload();
    },
  },
  components: {},
  mounted() {
    // getLoginLog().then((res) => {
    //   console.log(res);
    // });
  },
};
</script>

<style scoped>
.quit {
  cursor: pointer;
  color: hotpink;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
  color: white;
}
.row-bg {
  padding: 10px 0;
  background-color: pink;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
#home .sao {
  width: 100%;
  height: 70px;
  text-align: center;
  line-height: 70px;
  box-sizing: border-box;
}
#home .sao img {
  width: 40px;
  margin-top: 15px;
  border-radius: 50%;
}
</style>

